﻿using System;
using GameFramework.common;
using UnityEngine;

namespace Game.modules.state
{
    /// <summary>
    /// 状态管理器，应该是单线程的
    /// </summary>
    public class StateManager
    {
        //long 64位，64种状态
        //long不满足可以弄成bitmap
        private long _allState;

        
        /// <summary>
        /// 增加状态
        /// </summary>
        /// <param name="state"></param>
        /// <returns></returns>
        public bool addState(State state)
        {
            
            return true;
        }
        /// <summary>
        /// 移除状态
        /// </summary>
        /// <param name="state"></param>
        /// <returns></returns>
        public bool removeState(State state)
        {
            return true;
        }
        /// <summary>
        /// 判断释放在某个状态下
        /// </summary>
        /// <param name="state"></param>
        /// <returns></returns>
        public bool inState(State state)
        {
            Int32 stateValue = Convert.ToInt16(state);
            if (stateValue > 64)
            {
                Debug.LogError("状态位超过上限，状态位最大位64，当前判断状态位："+stateValue);
                return false;
            }

            long result = _allState & (1 << (stateValue - 1));
            return result>0;
        }
    }
}